<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>用户登录</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
	<link rel="stylesheet" type="text/css" href="/css/base.css">
	<link rel="stylesheet" type="text/css" href="/css/login.css">
</head>
<body onkeydown="keylogin(event)">
<div class="userLogin">
	<div class="loginTitle">
		<div class="loginTitleMind">前锋图书馆</div>
	</div>
    <div class="notified">
            <div class="uname"><marquee class="marinfo">{$rollinfo|default='欢迎登录前锋图书管理系统'}</marquee></div>
        </div>
	<div class="userLoginMind">
		<div class="userName">
			<div class="uname">账号：</div><input type="text" name="uname" class="name_c" placeholder="请输入账号">
		</div>
		<div class="userPass">
			<div class="upass">密码：</div><input type="password" name="pass" class="pwd_c" placeholder="请输入密码(注意大小写)">
		</div>
		<div class="loginBtn">
			<div class="userLoginBtn do_login">登 录</div>
		</div>
	</div>
</div>
</body>
<script src="/js/jquery-3.1.1.min.js"></script>
 <script src="/js/layer/layer.js"></script>
<script type="text/javascript">

	function keylogin(event){
        if(event.keyCode==13){
            $('.do_login').click();
        }
    }

    $('.do_login').click(function(){
        var name = $('.name_c').val();
        var pwd = $('.pwd_c').val();
        if(!name){
            layer.tips('输入账号', '.name_c');
            return false;
        }
        if(!pwd){
            layer.tips('输入密码', '.pwd_c');
            return false;
        }
        var index = layer.load(1, {
            shade: [0.1, '#fff']
        });
        $.ajax({
            type: "POST",
            url: "/index/index/dologin",
            data: {'name': name,'pwd': pwd},
            dataType: "json",
            timeout: 3000,
            success: function (data) {
                layer.close(index);
                console.log(data)
                if(data==1){
                    layer.msg('操作成功！', {
                        icon: 1,
                        time: 1000
                    }, function () {
                        window.location.href = "/index/index/index";
                    });
                }else if(data==2){
                	layer.msg('操作成功！', {
                        icon: 1,
                        time: 1000
                    }, function () {
                        window.location.href = "/admin/index/index";
                    });
                }else{
                    layer.alert(data.msg, {icon: 2}, function () {
                    layer.closeAll();
                });   
               }

           }
       });
    })

</script>
</html>